/**
 * 实名认证
 */
define(function (require, exports, module) {


    var UITip = require("ui/tip");


    var reg_email = /^([\w\.-]{1,64}@[\w\.-]{1,252}\.\w{2,4})$/;
    var reg_phone = /^[1][358][0-9]{9}$/;
    var $helpCenter = $("#helpCenter"), $form = $helpCenter.find("form");

    var $ipt = $form.find(".G_ipt"), $email = $ipt.eq(0), $phone = $ipt.eq(1), $textarea = $form.find("textarea")
    $form.find(".btnWrap button").unbind("click.sub").bind("click.sub", function () {
        var _email = $.trim($email.val()), _phone = $.trim($phone.val()), _area = $.trim($textarea.val());
        var emailTip = new UITip($email, "请输入您的邮箱地址", "top");
        var phoneTip = new UITip($phone, "请输入您的手机号码", "top");
        if (!_email) {
            emailTip.show();
            $email.focus();
            return false;
        } else if (!_email.match(reg_email)) {
            emailTip.show("请输入正确格式的邮箱地址");
            $email.focus();
            return false;
        }

        if (!_phone) {
            phoneTip.show();
            $phone.focus();
            return false;
        } else if (!_phone.match(reg_phone)) {
            phoneTip.show("请输入正确格式的手机号码");
            $phone.focus();
            return false;
        }
        if (!_area) {
            var areaTip = new UITip($textarea, "请输入您的留言", "right");
            areaTip.show();
            $textarea.focus();
            return false;
        }
    })

    var $txtTip=$textarea.siblings("span");
    $textarea.unbind("focus.txt").unbind("blur.txt").bind({
        "focus.txt": function () {
            var _val=$.trim($textarea.val())
            if(_val){
                $txtTip.hide();
            }
        },
        "blur.txt": function () {
            var _val=$.trim($textarea.val())
            if(!_val){
                $txtTip.show();
            }
        }
    })



})